TGML Custom Conversion: <ConvertCustom>
ConvertCustom defines a custom conversion of a signal value. The ConvertCustom element is a script element with a JavaScript function named 'convert'.
Example JavaScript convert function:
Copy
                                            
                                        
                                        function convert(value)
{
    //To do: add conversion code here
    
    return value;
}
                                            The function takes one parameter which is the signal value and returns a converted value.
The user can insert any valid JavaScript code in the function body to accomplish a value conversion. By default the function just returns the signal value as is.
Example ConvertCustom element:
Copy
                                            
                                        
                                        <TGML>
    <Rectangle Left="10" Top="10" Width="100" Height="50" Fill="#FFFF00" Stroke="#000000">
        <Bind Name="Temp" Attribute="Fill">
            <ConvertCustom> <![CDATA [ 
            function convert(value)
            {
                if(value >= 18 && value <= 22) 
                    value = "#00FF00" 
                else
                    value = "#FF0000" 
                return value ;
            }
            ]]> </ConvertCustcm>
        </Bind>
    </Rectangle>
</TGML>